home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 62
/
Volume 62 - JOGO DISK .iso
/
Games
/
penguin_dinner.swf
/
scripts
/
__Packages
/
com
/
potapenko
/
managers
/
Conv.as
Wrap
Text File
|
2008-03-17
|
17KB
|
583 lines
class com.potapenko.managers.Conv extends Object
{
var __conveyorON = true;
var __interval = 0;
var __bookmarks = 0;
var __shorts = 0;
var __turbo = false;
var __noSound = false;
var length = 0;
var isEmpty = true;
static var easingFunc = mx.transitions.easing.Strong.easeInOut;
static var __init = false;
static var gid = 0;
var id = 0;
var notTimeMode = false;
function Conv(notFrames)
{
super();
this.id = com.potapenko.managers.Conv.gid++;
this.__aConveyor = new Array();
com.potapenko.managers.Conv.checkForReloading();
if(!com.potapenko.managers.Conv.__init)
{
com.potapenko.managers.Conv.__init = true;
mx.transitions.OnEnterFrameBeacon.init();
}
if(!notFrames)
{
this.__frameTimer = new Object();
this.__frameTimer.root = this;
this.__frameTimer.sleep = true;
this.__frameTimer.onEnterFrame = function()
{
this.nTime = this.nTime + 1;
if(!this.sleep && this.nTime >= this.timeOut)
{
this.root.engine();
this.nTime = 0;
}
};
}
}
static function getInstance()
{
com.potapenko.managers.Conv.checkForReloading();
if(!com.potapenko.managers.Conv.__instance)
{
com.potapenko.managers.Conv.__instance = new com.potapenko.managers.Conv();
}
return com.potapenko.managers.Conv.__instance;
}
static function checkForReloading()
{
if(!_root.__OnEnterFrameBeacon)
{
com.potapenko.managers.Conv.__init = false;
if(com.potapenko.managers.Conv.__instance)
{
com.potapenko.managers.Conv.__instance.close();
delete com.potapenko.managers.Conv.__instance;
}
}
}
function play()
{
if(this.__conveyorON)
{
return undefined;
}
this.__conveyorON = true;
}
function stop()
{
this.__conveyorON = false;
}
function pause(p)
{
this.__aConveyor = [[this.empty,p,new com.potapenko.managers.conveyor.ConvReturn()]].concat(this.__aConveyor);
}
function addPause(p)
{
this.put(this.empty,p);
}
function clear()
{
this.__aConveyor = new Array();
this.__bookmarks = 0;
this.__shorts = 0;
}
function put()
{
var _loc3_ = new com.potapenko.managers.conveyor.ConvReturn();
if(this.__noSound && arguments[1] == "newSound")
{
return _loc3_;
}
arguments.push(_loc3_);
this.__aConveyor.push(arguments);
this.length = this.length + 1;
if(!this.__bookmarks && this.__aConveyor.length > 200 + this.__shorts)
{
var _loc4_ = this.__aConveyor.splice(100 + this.__shorts);
this.__shorts = this.__shorts + 1;
this.put(this,"__removeShort",0,_loc4_);
}
if(this.isEmpty)
{
this.wakeup();
}
return _loc3_;
}
function include()
{
this.put(this,"__addBookmark",0);
var _loc3_ = this.put.apply(this,arguments);
this.put(this,"__removeBookmark",0);
return _loc3_;
}
function anim(mc_anim, mc_to, params_ob)
{
var _loc7_ = params_ob.to_end;
var _loc21_ = params_ob.speed;
var _loc23_ = params_ob.notSwap;
var _loc13_ = params_ob.scale;
var _loc26_ = mc_to._x;
var _loc28_ = mc_to._y;
var _loc22_ = params_ob.delta;
var _loc5_ = params_ob.easing;
var _loc17_ = params_ob.frame || "1";
var _loc20_ = params_ob.duration;
var _loc24_ = params_ob.sound;
mc_to = this.validatePointScope(mc_anim,mc_to);
_loc22_ = this.validatePointScope(mc_anim,_loc22_);
if(!_loc21_)
{
_loc21_ = 20;
}
if(!_loc5_)
{
_loc5_ = com.potapenko.managers.Conv.easingFunc;
}
var _loc29_ = mc_anim._x;
var _loc27_ = mc_anim._y;
var _loc10_ = undefined;
var _loc9_ = undefined;
var _loc11_ = undefined;
var _loc12_ = undefined;
var _loc16_ = undefined;
var _loc15_ = undefined;
var _loc18_ = undefined;
var _loc19_ = undefined;
if(_loc13_)
{
_loc16_ = mc_anim._xscale;
_loc15_ = mc_anim._yscale;
_loc18_ = mc_to._xscale - _loc16_;
_loc19_ = mc_to._yscale - _loc15_;
}
var _loc25_ = undefined;
_loc25_ = Math.sqrt(Math.pow(Math.abs(mc_anim._x - mc_to._x),2) + Math.pow(Math.abs(mc_anim._y - mc_to._y),2));
var _loc6_ = this.__calculatePath(mc_anim,mc_to,_loc22_,_loc21_,_loc5_,_loc20_);
var _loc3_ = _loc6_.length;
if(_loc20_)
{
if(typeof _loc20_ == "string")
{
_loc3_ = _loc20_;
}
else
{
_loc17_ = _loc20_ / _loc3_;
}
}
if(isNaN(_loc3_))
{
return null;
}
if(!_loc23_)
{
this.put(this.__newDepth,mc_anim,0);
}
if(_loc24_)
{
this.put(new com.potapenko.util.MovieClipUtil(mc_anim),"newSound",0,"movie",50);
}
var _loc2_ = 1;
while(_loc2_ <= _loc3_)
{
if(!_loc7_ && _loc2_ >= _loc3_ - _loc3_ / 5)
{
break;
}
if(this.__turbo)
{
_loc2_ = !_loc7_ ? _loc3_ - _loc3_ / 5 : _loc3_;
}
if(_loc13_)
{
_loc11_ = _loc5_(_loc2_,_loc16_,_loc18_,_loc3_);
_loc12_ = _loc5_(_loc2_,_loc15_,_loc19_,_loc3_);
this.put(this.__scaleTo,0,mc_anim,_loc11_,_loc12_);
}
_loc10_ = _loc6_[_loc2_ - 1]._x;
_loc9_ = _loc6_[_loc2_ - 1]._y;
this.put(this.__moveTo,_loc17_,mc_anim,_loc10_,_loc9_);
_loc2_ = _loc2_ + 1;
}
if(!_loc23_)
{
this.put(this.__restoreDepth,mc_anim,0);
}
this.put(mc_anim,"_x",0,mc_to._x);
this.put(mc_anim,"_y",0,mc_to._y);
if(_loc13_)
{
this.put(mc_anim,"_xscale",0,mc_to._xscale);
this.put(mc_anim,"_yscale",0,mc_to._yscale);
}
return _loc6_;
}
function reverse()
{
this.__aConveyor.reverse();
}
function turbo_On()
{
this.__turbo = true;
}
function turbo_Off()
{
this.__turbo = false;
}
static function create(notFrames)
{
return new com.potapenko.managers.Conv(notFrames);
}
static function setTimeout()
{
var _loc3_ = 1;
var _loc4_ = arguments[_loc3_];
var _loc2_ = com.potapenko.managers.Conv.create();
if(isNaN(_loc4_))
{
_loc3_ = 2;
_loc4_ = arguments[_loc3_];
}
arguments[_loc3_] = 0;
_loc2_.addPause(_loc4_);
_loc2_.put.apply(_loc2_,arguments);
_loc2_.put(_loc2_,"close",0);
}
function close()
{
stop();
this.clear();
_global.MovieClip.removeListener(this.__frameTimer);
clearInterval(this.__interval);
}
function engine()
{
if(!this.__conveyorON)
{
this.pause("1");
}
clearInterval(this.__interval);
var cTime;
var tA = this.__aConveyor[0];
if(this.__aConveyor.length == 0)
{
this.sleep();
return undefined;
}
this.__aConveyor.shift();
this.length--;
var calledFunction;
var calledObject;
var argumentsObject;
var convReturn = tA.pop();
if(typeof tA[0] != "function")
{
calledObject = tA[0];
if(typeof calledObject == "string")
{
calledObject = eval(calledObject);
}
cTime = tA[2];
calledFunction = calledObject[tA[1]];
argumentsObject = tA.slice(3);
if(typeof calledFunction == "function")
{
convReturn.setReturnValue(calledFunction.apply(calledObject,this.validateArgs(argumentsObject)));
}
else
{
calledObject[tA[1]] = argumentsObject[0];
}
}
else if(!isNaN(tA[1]))
{
cTime = tA[1];
calledFunction = tA[0];
argumentsObject = tA.slice(2);
convReturn.setReturnValue(calledFunction.apply(null,this.validateArgs(argumentsObject)));
}
else if(!isNaN(tA[2]))
{
cTime = tA[2];
calledFunction = tA[0];
calledObject = tA[1];
if(typeof calledObject == "string")
{
calledObject = eval(calledObject);
}
argumentsObject = tA.slice(3);
convReturn.setReturnValue(calledFunction.apply(calledObject,this.validateArgs(argumentsObject)));
}
else
{
trace("com.potapenko.managers.Conv: engine: time format error");
}
if(cTime != 0 && !this.notTimeMode)
{
var timeType = typeof cTime;
var timeValue = Number(cTime);
if(timeType == "string")
{
if(this.__turbo)
{
timeValue = 1;
}
this.__frameTimer.timeOut = timeValue;
this.__frameTimer.nTime = 0;
this.__frameTimer.sleep = false;
this.__frame = true;
}
else if(timeType == "number")
{
this.__interval = setInterval(this,"engine",timeValue);
this.__frameTimer.sleep = true;
this.__frame = false;
}
else
{
this.engine();
}
}
else
{
this.engine();
}
}
function validateArgs(args)
{
var _loc1_ = 0;
while(_loc1_ < args.length)
{
var _loc2_ = args[_loc1_];
if(_loc2_ instanceof com.potapenko.managers.conveyor.ConvReturn)
{
args[_loc1_] = _loc2_.getReturnValue();
}
_loc1_ = _loc1_ + 1;
}
return args;
}
function sleep()
{
this.isEmpty = true;
if(this.__frameTimer)
{
_global.MovieClip.removeListener(this.__frameTimer);
}
}
function wakeup(isFrames)
{
this.isEmpty = false;
if(this.__frameTimer)
{
_global.MovieClip.addListener(this.__frameTimer);
}
this.engine();
}
function __removeShort()
{
this.__aConveyor = arguments[0].concat(this.__aConveyor);
this.__shorts = this.__shorts - 1;
}
function __addBookmark()
{
this.__aConveyor.push("#__bookmarks#");
this.__bookmarks = this.__bookmarks + 1;
}
function __removeBookmark(rev)
{
if(this.__bookmarks <= 0)
{
return undefined;
}
this.__bookmarks = this.__bookmarks - 1;
var _loc3_ = this.__aConveyor.length;
var _loc2_ = [];
while(this.__aConveyor[this.__aConveyor.length - 1] != "#__bookmarks#" && _loc3_-- > 0)
{
_loc2_.push(this.__aConveyor.pop());
}
this.__aConveyor.pop();
if(!rev)
{
_loc2_.reverse();
}
this.__aConveyor = _loc2_.concat(this.__aConveyor);
}
function __newDepth()
{
var _loc2_ = this;
_loc2_.____conv_anim_depth____ = _loc2_.getDepth();
var _loc3_ = _loc2_._parent.getNextHighestDepth();
if(!_loc3_ || _loc3_ < 0)
{
_loc3_ = 12123;
}
_loc2_.swapDepths(_loc3_);
}
function __restoreDepth()
{
var _loc2_ = this;
_loc2_.swapDepths(_loc2_.____conv_anim_depth____);
delete _loc2_.____conv_anim_depth____;
}
function __moveTo(mc, x, y)
{
mc._x = Math.round(x);
mc._y = Math.round(y);
}
function __scaleTo(mc, xs, ys)
{
mc._xscale = Math.round(xs);
mc._yscale = Math.round(ys);
}
function __calculatePath(start, to_point, delta, speed, func, duration)
{
var _loc21_ = [];
if(delta)
{
var _loc13_ = mx.transitions.easing.Regular.easeInOut;
var _loc12_ = mx.transitions.easing.Regular.easeInOut;
var _loc14_ = mx.transitions.easing.Regular.easeInOut;
var _loc27_ = {};
var _loc2_ = start;
var _loc7_ = to_point;
var _loc23_ = delta;
var _loc3_ = {};
_loc27_._x = (_loc2_._x + _loc7_._x) / 2;
_loc27_._y = (_loc2_._y + _loc7_._y) / 2;
_loc3_._x = _loc23_._x + (_loc23_._x - _loc27_._x);
_loc3_._y = _loc23_._y + (_loc23_._y - _loc27_._y);
var _loc4_ = [];
var _loc8_ = [];
var _loc35_ = this.__lengthCalculator(_loc2_,_loc7_);
var _loc32_ = this.__lengthCalculator(_loc2_,_loc23_);
var _loc31_ = this.__lengthCalculator(_loc23_,_loc7_);
var _loc30_ = _loc32_ + _loc31_;
var _loc9_ = undefined;
if(duration && typeof duration == "string")
{
_loc9_ = Number(duration);
}
else
{
_loc9_ = Math.round(_loc30_ / speed);
}
if(_loc9_ < 5 && !duration)
{
_loc9_ = 5;
}
if(duration)
{
_loc9_ = parseInt(duration);
}
if(_loc9_ < 5)
{
_loc9_ = 5;
}
var _loc10_ = Math.round(_loc9_ / 2);
var _loc11_ = _loc9_ - _loc10_;
var _loc16_ = undefined;
var _loc15_ = undefined;
var _loc5_ = undefined;
var _loc6_ = 1;
while(_loc6_ <= _loc9_)
{
_loc16_ = _loc14_(_loc6_,_loc2_._x,_loc7_._x - _loc2_._x,_loc9_);
_loc15_ = _loc14_(_loc6_,_loc2_._y,_loc7_._y - _loc2_._y,_loc9_);
_loc5_ = {_x:_loc16_,_y:_loc15_};
_loc4_.push(_loc5_);
_loc6_ = _loc6_ + 1;
}
_loc6_ = 1;
while(_loc6_ <= _loc10_)
{
_loc16_ = _loc13_(_loc6_,_loc2_._x,_loc3_._x - _loc2_._x,_loc10_);
_loc15_ = _loc13_(_loc6_,_loc2_._y,_loc3_._y - _loc2_._y,_loc10_);
_loc5_ = {_x:_loc16_,_y:_loc15_};
_loc8_.push(_loc5_);
_loc6_ = _loc6_ + 1;
}
_loc6_ = 1;
while(_loc6_ <= _loc11_)
{
_loc16_ = _loc12_(_loc6_,_loc3_._x,_loc7_._x - _loc3_._x,_loc11_);
_loc15_ = _loc12_(_loc6_,_loc3_._y,_loc7_._y - _loc3_._y,_loc11_);
_loc5_ = {_x:_loc16_,_y:_loc15_};
_loc8_.push(_loc5_);
_loc6_ = _loc6_ + 1;
}
_loc6_ = 0;
while(_loc6_ < _loc4_.length)
{
_loc4_[_loc6_]._x = (_loc4_[_loc6_]._x + _loc8_[_loc6_]._x) / 2;
_loc4_[_loc6_]._y = (_loc4_[_loc6_]._y + _loc8_[_loc6_]._y) / 2;
_loc6_ = _loc6_ + 1;
}
_loc21_ = _loc4_;
}
else
{
_loc30_ = this.__lengthCalculator(start,to_point);
if(duration && typeof duration == "string")
{
_loc9_ = Number(duration);
}
else
{
_loc9_ = Math.round(_loc30_ / speed);
}
if(_loc9_ < 5 && !duration)
{
_loc9_ = 5;
}
var _loc25_ = to_point._x - start._x;
var _loc24_ = to_point._y - start._y;
var _loc22_ = start._x;
var _loc26_ = start._y;
_loc6_ = 1;
while(_loc6_ <= _loc9_)
{
_loc16_ = func(_loc6_,_loc22_,_loc25_,_loc9_);
_loc15_ = func(_loc6_,_loc26_,_loc24_,_loc9_);
_loc21_.push({_x:_loc16_,_y:_loc15_});
_loc6_ = _loc6_ + 1;
}
}
return _loc21_;
}
function __lengthCalculator(a, b)
{
return Math.sqrt(Math.pow(Math.abs(a._x - b._x),2) + Math.pow(Math.abs(a._y - b._y),2));
}
function validatePointScope(animatedPoint, point)
{
if(point == null || typeof point != "movieclip")
{
return point;
}
var _loc2_ = {x:point._x,y:point._y};
point._parent.localToGlobal(_loc2_);
animatedPoint._parent.globalToLocal(_loc2_);
var _loc3_ = {_x:_loc2_.x,_y:_loc2_.y,_xscale:point._xscale,_yscale:point._yscale,_width:point._width,_height:point._height};
return _loc3_;
}
function isNotTimeMode()
{
return this.notTimeMode;
}
function setNotTimeMode(notTimeMode)
{
this.notTimeMode = notTimeMode;
}
function empty()
{
}
}